package com.ucode.cgms.mapper;

import com.ucode.model.cgms.CgmsCompanionOrder;
import com.ucode.springboot.starter.mybatis.core.base.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 陪玩订单 Mapper
 * @Author: liliang
 * @Date: 2025/5/11 13:49
 * @Version: 1.0
 */
@Mapper
public interface CgmsCompanionOrderMapper extends BaseMapper<CgmsCompanionOrder, Long> {

    /**
     * 更新订单支付成功
     * @param id 订单ID
     * @param status 更新状态
     * @param payOrderId 支付订单编号
     * @param payType 支付类型
     * @param payTime 支付时间
     * @return
     */
    public int paySuccess(@Param("id") Long id, @Param("status") Integer status, @Param("payOrderId") Long payOrderId, @Param("payType") String payType, @Param("payTime") LocalDateTime payTime);

    /**
     * 取消订单
     * @param id
     * @return
     */
    public int cancel(Long id);

    /***
     * 确认接单
     * @param id
     * @param confirmedTime
     * @return
     */
    public int confirmReceive(@Param("id")Long id,@Param("confirmedTime")LocalDateTime confirmedTime);

    /**
     * 用户拒绝接单，订单状态变更为派单中
     * @param id
     */
    public int refuseReceive(Long id);

    /**
     * 完工报备
     * @param bean
     * @return
     */
    public int companionReport(CgmsCompanionOrder bean);

    /**
     * 确认完工
     * @param bean
     * @return
     */
    public int confirmCompleted(CgmsCompanionOrder bean);

    /**
     * 抢单
     * @param id
     * @param serviceUserId
     * @param dispatchedTime
     * @return
     */
    public int snatchOrder(@Param("id")Long id,@Param("serviceUserId")Long serviceUserId,@Param("dispatchedTime") LocalDateTime dispatchedTime);

    /**
     * 派单（派单后，需要确认接单）
     * @param id
     * @param serviceUserId
     * @param dispatchedTime
     * @return
     */
    public int designateOrder(@Param("id")Long id,@Param("serviceUserId")Long serviceUserId,@Param("dispatchedTime") LocalDateTime dispatchedTime);

    /**
     * 更新售后状态
     * @param id
     * @param afterSaleState true售后中  false 未售后
     * @param refundQuantity 只用来做条件判断，不用来实际操作
     * @return
     */
    public int updateAfterSaleState(@Param("id")Long id,@Param("afterSaleState")Boolean afterSaleState,@Param("refundQuantity")Integer refundQuantity);

    /**
     * 售后结果更新
     * @param id
     * @param refundQuantity 售后数量
     * @param refundAmount 售后金额
     * @param afterSaleState 是否已全部售后
     * @return
     */
    public int updateAfterSaleResult(@Param("id")Long id,@Param("refundQuantity") Integer refundQuantity,@Param("refundAmount") BigDecimal refundAmount,@Param("afterSaleState") Boolean afterSaleState);
}
